Skip to content

refactor: publish releases with limited concurrency #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2025

Conversation

jean-smaug
Copy link
Contributor

@jean-smaug jean-smaug commented Mar 31, 2025

Think it could fix #188

Need to do additional tests on my side

Summary by CodeRabbit

  • Chores
    • Introduced a new concurrency control mechanism for the release publishing process, limiting concurrent executions to improve API call management.
    • Added a new dependency, p-limit, to enhance the release workflow.

Copy link

changeset-bot bot commented Mar 31, 2025

🦋 Changeset detected

Latest commit: efc0650

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
changesets-gitlab Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Mar 31, 2025

Walkthrough

The pull request modifies the runPublish function in src/run.ts by introducing a concurrency control mechanism for creating GitLab releases. It replaces the previous implementation using Promise.all with a limit on concurrent executions, utilizing the pLimit library to allow a maximum of 6 concurrent API calls. The overall logic and error handling of the release process remain unchanged.

Changes

File(s) Change Summary
src/run.ts Updated the runPublish function to use pLimit for controlling concurrency during GitLab release creation.
.changeset/ten-eagles-sing.md Added a new changeset entry documenting the refactor related to concurrency management in the release publishing process.
package.json Added p-limit as a new dependency in devDependencies.

Assessment against linked issues

Objective Addressed Explanation
Job fails with Service Unavailable when releasing multiple packages (#188)

Possibly related PRs

  • feat: fetch the tags and push each one individually #195: The changes in the main PR focus on implementing a concurrency control mechanism in the runPublish function, while the retrieved PR modifies the runPublish function to handle tag pushing logic; thus, they are related at the code level.

Poem

I'm hopping through the code with cheer,
One release at a time, my path is clear.
No more frantic leaps that cause a fuss,
Each package shines without a rush.
A joyful bounce to smoother, steady flow!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/run.ts

Oops! Something went wrong! :(

ESLint: 9.23.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.js
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codesandbox-ci bot commented Mar 31, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/run.ts (1)

146-151: LGTM! Good refactoring to sequential release publication.

The change from concurrent (likely using Promise.all) to sequential release creation is a good approach. Sequential execution can help avoid potential rate limiting issues with GitLab's API and ensures releases are processed in a predictable order. This aligns well with the PR objective to "publish release sequentially" and likely addresses the referenced issue #188.

Consider adding a comment explaining why sequential execution is preferred over concurrent execution to help future maintainers understand the design decision:

    if (createGitlabReleases) {
+     // Process releases sequentially to avoid rate limiting and ensure consistent order
      for (const pkg of releasedPackages) {
        await createRelease(api, {
          pkg,
          tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
        })
      }
    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1276718 and 1b1820c.

📒 Files selected for processing (1)
  • src/run.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis

@JounQin
Copy link
Member

JounQin commented Mar 31, 2025

This should be opt-in at least.

@JounQin JounQin changed the title refactor: publish release sequencially refactor: publish releases with limited concurrency Apr 1, 2025
Copy link

sonarqubecloud bot commented Apr 1, 2025

@JounQin
Copy link
Member

JounQin commented Apr 1, 2025

@codecov-ai-reviewer review

Copy link

codecov-ai bot commented Apr 1, 2025

On it! We are reviewing the PR and will provide feedback shortly.

@JounQin JounQin requested a review from Copilot April 1, 2025 10:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the release process to publish releases with limited concurrency using the p-limit library. Key changes include:

  • Importing and using the p-limit library to limit concurrent release operations.
  • Wrapping the createRelease call in a concurrency-limited function within Promise.all.
  • Updating the changeset to reflect the concurrency refactor.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
src/run.ts Introduces p-limit to constrain concurrent release creation.
.changeset/ten-eagles-sing.md Updates the release notes to reflect the concurrency refactor change.
Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (1)

src/run.ts:27

  • [nitpick] Consider replacing the computed expression (2 * 3) with a descriptive named constant (e.g., const CONCURRENCY_LIMIT = 6) to improve clarity.
const limit = pLimit(2 * 3)

Copy link

pkg-pr-new bot commented Apr 1, 2025

Open in StackBlitz

npm i https://pkg.pr.new/changesets-gitlab@206

commit: efc0650

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
package.json (1)

88-88: Critical Dependency Categorization:
The p-limit package is now added to the devDependencies at line 88. Please verify whether this module is used by production code (for example, in the src/run.ts file as part of the limited concurrency implementation for publishing releases). If it is indeed used at runtime rather than solely in development scripts, it should be moved to the dependencies section to ensure that it is available when the package is installed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b1820c and efc0650.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • .changeset/ten-eagles-sing.md (1 hunks)
  • package.json (1 hunks)
  • src/run.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/ten-eagles-sing.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/run.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Codacy Static Code Analysis

@JounQin
Copy link
Member

JounQin commented Apr 1, 2025

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

@coderabbitai This repository use yarn@4+ to manage dependencies, that should be absolutely fine and Cannot find package '@1stg/eslint-config' imported from /eslint.config.js should never happen.

Copy link

coderabbitai bot commented Apr 1, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check repository structure
echo "=== Repository Structure ==="
ls -la

# Check package.json content
echo -e "\n=== Package.json Content ==="
cat package.json

# Check ESLint config
echo -e "\n=== ESLint Config ==="
cat eslint.config.js 2>/dev/null || echo "eslint.config.js not found"

# Check Yarn configuration
echo -e "\n=== Yarn Configuration ==="
cat .yarnrc.yml 2>/dev/null || echo ".yarnrc.yml not found"

# Check if the package exists in node_modules
echo -e "\n=== Check for @1stg/eslint-config ==="
find . -path "*@1stg/eslint-config*" 2>/dev/null || echo "Package not found in standard location"

# Check Yarn version
echo -e "\n=== Yarn Version ==="
cat .yarn/releases/* 2>/dev/null | grep -i "yarnpkg" | head -n 5 || echo "Yarn release info not found"

Length of output: 75859


🏁 Script executed:

#!/bin/bash
# Check more about the directory structure and dependencies
echo "=== Looking for @1stg/eslint-config in node_modules ==="
find . -name "node_modules" -type d -exec ls -la {} \; 2>/dev/null

# Check the changed files in the PR
echo -e "\n=== PR Changed Files ==="
cat src/run.ts

# Check if @1stg/eslint-config is a dependency of @1stg/common-config
echo -e "\n=== Checking package dependencies ==="
ls node_modules/@1stg 2>/dev/null || echo "No @1stg folder in node_modules"

# Check the changeset file
echo -e "\n=== Changeset File ==="
cat .changeset/ten-eagles-sing.md 2>/dev/null || echo "Changeset file not found"

Length of output: 10666


@JounQin I apologize for the issue you're experiencing with the ESLint configuration. After investigating your repository setup, I can see the problem:

  1. Your repository uses Yarn v4+ as the package manager
  2. You have eslint.config.js that imports @1stg/eslint-config
  3. The @1stg/eslint-config package is not directly installed (likely a dependency of @1stg/common-config)
  4. When running the review, our environment cannot resolve this dependency

This is an issue with our review tools not properly resolving dependencies in Yarn v4+ projects. The error Cannot find package '@1stg/eslint-config' imported from /eslint.config.js is occurring because our review environment isn't correctly handling Yarn's dependency resolution.

I'll report this issue to our engineering team to improve compatibility with Yarn v4+ projects. In the meantime, you have a few options:

  1. Add @1stg/eslint-config as a direct dependency
  2. Configure CodeRabbit to skip ESLint checks in reviews through the UI or YAML configuration
  3. Temporarily add comments to disable specific ESLint rules that are causing problems

Thank you for bringing this to our attention. We'll work on improving our compatibility with modern Yarn workspaces.

@JounQin JounQin merged commit 842110d into un-ts:main Apr 1, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Job fails with Service Unavailable when releasing multiple packages
2 participants